
<%@ page import="org.hr.xtime.absence.Request" %>
<!doctype html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'request.label', default: 'Request')}" />
		<title><g:message code="default.list.label" args="[entityName]" /></title>
	</head>
	<body>
		<a href="#list-request" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
		<div class="nav" role="navigation">
			<ul>
				<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
				<li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
			</ul>
		</div>
		<div id="list-request" class="content scaffold-list" role="main">
			<h1><g:message code="default.list.label" args="[entityName]" /></h1>
			<g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<table>
				<thead>
					<tr>
						<g:sortableColumn property="id" title="Id" />
						<g:sortableColumn property="days" title="${message(code: 'request.days.label')}" />
						<g:sortableColumn property="type" title="${message(code: 'request.type.label')}" />
						<g:sortableColumn property="requestor" title="${message(code: 'request.requestor.label')}" />
						<g:sortableColumn property="approver" title="${message(code: 'request.approver.label')}" />
						<g:sortableColumn property="status" title="${message(code: 'request.status.label')}" />
						<g:sortableColumn property="requestDate" title="${message(code: 'request.requestDate.label')}" />
						<g:sortableColumn property="approvalDate" title="${message(code: 'request.approvalDate.label')}" />
						<th>${message(code: 'request.action.label')}</th>
					</tr>
				</thead>
				<tbody>
				<g:each in="${requestInstanceList}" status="i" var="requestInstance">
					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
						<td><g:link action="show" id="${requestInstance.id}">${requestInstance.id}</g:link></td>
					  	<td>
						  	<g:each in="${requestInstance.days}" var="day">
						  		${day.date?.format("dd/MM/yyyy")}<br />
						  	</g:each>
					  	</td>
					    <td>${requestInstance.days.toList().isEmpty()?'':requestInstance.days.toList().first().type}</td>
					    <td>${requestInstance.requestor}</td>
					    <td>${requestInstance.approver}</td>
					    <td>${requestInstance.status}</td>
					    <td>${requestInstance.requestDate?.format("dd/MM/yyyy")}</td>
					    <td>${requestInstance.approvalDate?.format("dd/MM/yyyy")}</td>
					    <td>
						    <g:link action="approve" id="${requestInstance.id}"><g:message code="default.approve.label"/> </g:link><br />
						    <g:link action="disapprove" id="${requestInstance.id}"><g:message code="default.disapprove.label"/> </g:link><br />
						    <g:link action="cancel" id="${requestInstance.id}"><g:message code="default.cancel.label"/> </g:link>
					    </td>
					</tr>
				</g:each>
				</tbody>
			</table>
			<div class="pagination">
				<g:paginate total="${requestInstanceTotal}" />
			</div>
		</div>
	</body>
</html>
